<?php

namespace app\common\model\newhouse;

use think\Model;


class NewhousePanorama extends Model
{





    // 表名
    protected $name = 'newhouse_panorama';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'lx_text',
        'status_text'
    ];



    public function getLxList()
    {
        return ['0' => __('Lx 0'), '1' => __('Lx 1')];
    }

    public function getStatusList()
    {
        return ['0' => __('Status 0'), '1' => __('Status 1')];
    }

    public function getFoviList()
    {
        return ['0' => __('Fovi 0'), '1' => __('Fovi 1'), '2' => __('Fovi 2'), '3' => __('Fovi 3'), '4' => __('Fovi 4'), '5' => __('Fovi 5'), '6' => __('Fovi 6'), '7' => __('Fovi 7'), '8' => __('Fovi 8'), '9' => __('Fovi 9')];
    }


    public function getLxTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['lx']) ? $data['lx'] : '');
        $list = $this->getLxList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getFoviTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['fovi']) ? $data['fovi'] : '');
        $list = $this->getFoviList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function admin()
    {
        return $this->belongsTo('app\admin\model\Admin', 'admin_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

    public function category()
    {
        return $this->belongsTo('app\common\model\Category', 'category_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
